﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<script>
    var keyValue = request('keyValue');
    var parentId = request('ParentId');
    var organizeId="@LeSoft.Application.Code.OperatorProvider.Provider.Current().CompanyId";
    $(function () {
        initControl();
    })
    //初始化控件
    function initControl() {    
        if (keyValue != "") organizeId = keyValue;
        //上级公司
        $("#ParentId").ComboBoxTree({
            url: "../../BaseManage/Organize/GetTreeJson?keyValue=" + keyValue,
            description: "==请选择==",
            height: "260px",
            allowSearch: true
        });
        //负责人
        $("#ManagerId").ComboBoxTree({
            url: "../../BaseManage/Worker/GetDptWorkerTreeJson?organizeid=" + organizeId,          
            description: "==请选择==",
            height: "200px"
        });
        //公司类型
        $('#BusinessScope').ComboBox({
            url: "../../SystemManage/DataItemDetail/GetDataItemListJson",
            param: { EnCode: "ProjectType" },
            id: "ItemDetailId",
            text: "ItemName",
            description: "==请选择==",
            height: "200px"
        });
        //获取表单
        if (!!keyValue) {
            $.SetForm({
                url: "../../BaseManage/Organize/GetFormJson",
                param: { keyValue: keyValue },
                success: function (data) {
                    $("#form1").SetWebControls(data);
                    $("#FoundedTime").val(formatDate(data.FoundedTime, "yyyy-MM-dd"));                 
                    $("#ParentId").ComboBoxSetValue(parentId);                   
                }
            });
        } else {
            
            $("#ParentId").ComboBoxSetValue(parentId);

        }
    }
    //保存表单
    function AcceptClick() {
        if (!$('#form1').Validform()) {
            return false;
        }
        var postData = $("#form1").GetWebControls(keyValue);
        if (postData["ParentId"] == "") {
            postData["ParentId"] = 0;
        }
        $.SaveForm({
            url: "../../BaseManage/Organize/SaveForm?keyValue=" + keyValue,
            param: postData,
            loading: "正在保存数据...",
            success: function () {
                $.currentIframe().$("#gridTable").resetSelection();
                $.currentIframe().$("#gridTable").trigger("reloadGrid");
            }
        })
    }
</script>
<div style="margin-left: 10px; margin-top: 20px; margin-right: 30px;">
    <table class="form">
        <tr>
            <th class="formTitle">公司名称<font face="宋体">*</font></th>
            <td class="formValue">
                <input id="FullName" type="text" onblur="$.ExistField(this.id,'../../BaseManage/Organize/ExistFullName')" class="form-control" isvalid="yes" checkexpession="NotNull" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">公司编号<font face="宋体">*</font></th>
            <td class="formValue">
                <input id="EnCode" type="text" onblur="$.ExistField(this.id,'../../BaseManage/Organize/ExistEnCode')" class="form-control" isvalid="yes" checkexpession="NotNull" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">隶属上级</th>
            <td class="formValue">
                <div id="ParentId" type="selectTree" class="ui-select" isvalid="yes" checkexpession="IsScript">
                </div>
            </td>
        </tr>     
        <tr>
            <th class="formTitle">负责人</th>
            <td class="formValue">             
                <div id="ManagerId" type="select" class="ui-select" isvalid="yes" checkexpession="IsScript">
                </div>
            </td>
              <tr>
                <th class="formTitle">
                    项目类型
                </th>
                <td class="formValue">
                    <div id="BusinessScope" type="select" class="ui-select" isvalid="yes" checkexpession="IsScript">
                    </div>
                </td>
            </tr>
        <tr>
            <th class="formTitle">成立时间</th>
            <td class="formValue">
                <input id="FoundedTime" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker()" isvalid="yes" checkexpession="DateTimeOrNull" />
            </td>
        </tr>
       
        </tr>
        <tr>
            <th class="formTitle">电话</th>
            <td class="formValue">
                <input id="OuterPhone" type="text" class="form-control" isvalid="yes" checkexpession="IsScript" />
            </td>

        </tr>
    @*<tr>
             <th class="formTitle">电子邮箱</th>
             <td class="formValue">
                 <input id="Email" type="text" class="form-control" />
             </td>
             <th class="formTitle">传真</th>
             <td class="formValue">
                 <input id="Fax" type="text" class="form-control" />
             </td>
         </tr>

         <tr>
             <th class="formTitle">公司地点</th>
             <td class="formValue" >
                 <div style="float: left; width: 255px;">
                     <div id="ProvinceId" type="select" class="ui-select" style="float: left; width: 84px; margin-right: 1px;"></div>
                     <div id="CityId" type="select" class="ui-select" style="float: left; width: 84px; margin-right: 1px;"></div>
                     <div id="CountyId" type="select" class="ui-select" style="float: left; width: 84px; margin-right: 1px;"></div>
                 </div>
                 <div style="margin: 0 auto; width: 100%;">
                     <input id="Address" type="text" class="form-control" style="float: left; width: 355px;" />
                 </div>
             </td>
         </tr>
    <tr>
             <th class="formTitle">邮编</th>
             <td class="formValue">
                 <input id="Postalcode" type="text" class="form-control" />
             </td>
             <th class="formTitle">公司官网</th>
             <td class="formValue">
                 <input id="WebAddress" type="text" class="form-control" isvalid="yes" checkexpession="UriOrNull"/>
             </td>
         </tr>*@

        <tr>
            <th class="formTitle" valign="top" style="padding-top: 4px;" >
                备注
            </th>
            <td class="formValue">
                <textarea id="Description" class="form-control" style="height: 70px;" isvalid="yes" checkexpession="IsScript"></textarea>
            </td>
        </tr>
    </table>
</div>

